#include <algorithm>
#include <cmath>
#include <cstdio>

const int N = 500005;
int n, q, num[N];
double sum[N];
double csum[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("T1.in", "r", stdin);
  freopen("T1.out", "w", stdout);
#endif
#endif
  scanf("%d%d", &n, &q);
  double tmp;
  for (int i = 1; i <= n; ++i) {
    scanf("%lf", &tmp);
    sum[i] = sum[i - 1] + tmp;
    csum[i] = csum[i - 1] + ceil(tmp);
    num[i] = num[i - 1] + ((tmp - floor(tmp)) < 1e-8 ? 1 : 0);
  }
  int l, r, len;
  while (q--) {
    scanf("%d%d", &l, &r);
    n = (r - l + 1) >> 1;
    len = r - l + 1;
    double Sum = sum[r] - sum[l - 1], Csum = csum[r] - csum[l - 1];
    int cnt = num[r] - num[l - 1];
    if (std::min(n, len - cnt) < Csum - Sum)
      Csum -= std::min(n, len - cnt);
    else {
      int tar =
          std::min(std::min(n, len - cnt), (int)(Csum - Sum + 0.5 - 1e-8));
      int tmp = n - tar;
      Csum -= tar;
      if (cnt < tmp) Csum -= tmp - cnt;
    }
    printf("%.3lf\n", fabs(Csum - Sum));
  }
  return 0;
}